package xyz.xtt.asset.enums;

import java.util.Arrays;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

/**
 * 用户信息同步事件
 * 
 * @author huqibo
 * @date 2024/12/19
 */
public enum SyncUserActionEnum {

	/**
	 * 创建
	 */
	CREATE(0, "创建"),
	/**
	 * 冻结
	 */
	UPDATE(1, "更新");

	/**
	 * 更新
	 */
	private int code;
	/**
	 * 描述
	 */
	private String desc;

	SyncUserActionEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(SyncUserActionEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static SyncUserActionEnum convert(String checkType) {
		return Arrays
				.asList(SyncUserActionEnum.values())
				.stream()
				.filter(x -> Objects.equals(x.name(), StringUtils.upperCase(StringUtils.trim(checkType))))
				.findAny()
				.orElse(null);
	}

}
